@ECHO OFF
		
REM.
REM.
REM -------------------------------------------------------------------------------
REM -------------------------------------------------------------------------------
REM -- Lazarus
REM --                                                                           
REM -- AlterProcs - Alters all Stored Procedures to provide implementation details.                                      
REM --                                                                           
REM -------------------------------------------------------------------------------
REM -------------------------------------------------------------------------------
REM.
REM.
REM.

if '%1' == '' goto usage
if '%2' == '' goto usage
if '%3' == '' goto usage
if '%4' == '' goto usage

if '%1' == '/?' goto usage
if '%1' == '-?' goto usage
if '%1' == '?' goto usage
if '%1' == '/help' goto usage


@ECHO Compilation started: %DATE% %TIME%
@ECHO.
@ECHO.

@ECHO Compiling stored procedure 'ExpertiseLevelCreate'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spExpertiseLevelCreate.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'ExpertiseLevelUpdate'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spExpertiseLevelUpdate.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'ExpertiseLevelGet'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spExpertiseLevelGet.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'ExpertiseLevelList'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spExpertiseLevelList.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'TechnologyCreate'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spTechnologyCreate.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'TechnologyUpdate'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spTechnologyUpdate.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'TechnologyGet'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spTechnologyGet.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'TechnologyList'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spTechnologyList.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalStatusCreate'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalStatusCreate.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalStatusUpdate'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalStatusUpdate.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalStatusGet'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalStatusGet.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalStatusList'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalStatusList.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalCreate'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalCreate.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalUpdate'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalUpdate.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalGet'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalGet.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalList'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalList.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalListByStatus'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalListByStatus.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalRequiredExpertiseCreate'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalRequiredExpertiseCreate.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalRequiredExpertiseUpdate'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalRequiredExpertiseUpdate.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalRequiredExpertiseGet'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalRequiredExpertiseGet.sql"
if %ERRORLEVEL% NEQ 0 goto errors

@ECHO Compiling stored procedure 'GoalRequiredExpertiseList'
osql -U %3  -P %4  -b  -S %1  -d %2  -n -i "spGoalRequiredExpertiseList.sql"
if %ERRORLEVEL% NEQ 0 goto errors



goto finish

REM: How to use screen
:usage
@ECHO.
@ECHO Usage: AlterProcs [Server] [Database] [User] [Password]
@ECHO.
@ECHO Options:
@ECHO    Server   - the name of the target SQL Server.
@ECHO    Database - the name of the target database.
@ECHO    User     - the SQL Server account login name.
@ECHO    Password - the SQL Server account password.
@ECHO.
@ECHO Example: AlterProcs.cmd DBServer\SQL2k MainDatabase bsmith pa$$w0rd
@ECHO.
@ECHO.
goto done

REM: error handler
:errors
@ECHO.
@ECHO WARNING! Error(s) were detected!
@ECHO --------------------------------
@ECHO Please evaluate the situation and, if needed,
@ECHO restart this command file. You may need to
@ECHO supply command parameters when executing
@ECHO this command file.
@ECHO.
pause
goto done

REM: finished execution
:finish
@ECHO.
@ECHO Script execution is complete!
:done
@ECHO on
   